#include "cppTutorInheritance.h"

extern CcppTutorLog Log;

CcppTutorCompanyEmployee :: CcppTutorCompanyEmployee () : m_nUserChoice (0), m_bFlag (true)
{
    // v_name_it = v_name.begin ();
    // v_dept_it = v_dept.begin ();
    // v_id_it   = v_id_it.begin ();
}

CcppTutorCompanyEmployee :: ~CcppTutorCompanyEmployee ()
{
}

void CcppTutorCompanyEmployee :: m_Menu ()
{
    Log << "ENTER : CcppTutorCompanyEmployee :: m_Menu" << endl;
    while (m_bFlag)
    {
        #ifdef WIN32
        system ("cls");
        #else
        system ("clear");
        #endif
        cout << "-------------------------------------------------" << endl;
        cout << "          New Employee Management System         " << endl;
        cout << "                 ccplusplus.com                  " << endl;
        cout << "-------------------------------------------------" << endl;
        cout << " Supported Operations                            " << endl;
        cout << endl;
        cout << endl;
        cout << " 1. Registration    -    Register a new Employee " << endl;
        cout << " 2. Search          -    Search an Employee      " << endl;
        cout << " 3. Delete          -    Remove an Employee      " << endl;
        cout << " 4. Quit the Registration                        " << endl;
        cout << endl;
        cout << "-------------------------------------------------" << endl;
        cout << "Please enter you choice" << endl;
        cin  >> m_nUserChoice;
        switch (m_nUserChoice)
        {
            case 1:
                m_RegisterEmployee ();
                m_bFlag = true;
                break;
                
            case 2:
                cout << "Not allowed/authorized." << endl;
                //m_SearchEmployee ();
                break;
              
            case 3:
                cout << "Not allowed/authorized." << endl;
                //m_DeleteEmployee ();
                break;

            case 4:
                m_bFlag = false;
                break;
            default:
                cout << "Not a supported choice. You can choose again in 10 seconds" << endl;
				SLEEP (10);
                break;
        }
    };
    Log << "EXIT  : CcppTutorCompanyEmployee :: m_Menu" << endl;
}

bool CcppTutorCompanyEmployee :: m_RegisterEmployee ()
{
    Log << "ENTER : CcppTutorCompanyEmployee :: m_RegisterEmployee" << endl;
    #ifdef WIN32
    system ("cls");
    #else
    system ("clear");
    #endif
    m_bFlag = true;
    while (m_bFlag)
    {
        cout << "-------------------------------------------------" << endl;
        cout << "            New Employee Registration            " << endl;
        cout << "                 ccplusplus.com                  " << endl;
        cout << "-------------------------------------------------" << endl;
        cout << " Fill the below entries to register a employee   " << endl;
        cout << endl;

        cout << " Emplyee Name : ";
        cin  >> m_strEmployeeName;
        v_name.push_back (m_strEmployeeName);
        cout << endl;

        cout << " Emplyee Department : ";
        cin  >> m_strDepartment;
        v_dept.push_back (m_strDepartment);
        cout << endl;

        cout << " Emplyee ID : ";
        cin  >> m_nEmployeeID;
        v_id.push_back (m_nEmployeeID);
        cout << endl << endl;
        cout << " Employee registratration done !!!" << endl;
        cout << "-------------------------------------------------" << endl;
        cout << " Redirecting to Main Menu....." << endl;
		SLEEP (10);

        m_bFlag = false;
    };
    Log << "EXIT  : CcppTutorCompanyEmployee :: m_RegisterEmployee" << endl;
    return true;
}

bool CcppTutorCompanyEmployee :: m_SearchEmployee ()
{
    Log  << "ENTER : CcppTutorCompanyEmployee :: m_SearchEmployee" << endl;

    int nUserChoice, nEmpID;
    string strName, strDepartment;
    
    cout << "Choose the search criteria [1/2/3]" << endl;
    cout << "1. By Name" << endl;
    cout << "2. By Employee ID" << endl;
    cout << "3. By Department" << endl;
    cout << "4. Quit Search Menu" << endl;
    cout << endl;
    cin  >> nUserChoice;

    m_bFlag = true;
    while (m_bFlag)
    {
        switch (nUserChoice)
        {
            case 1:
                cout << "Enter the employee name" << endl;
                cin  >> strName;
                cout << "Matched employees containg the name [" << strName << "]" << endl;
                for (v_name_it = v_name.begin (); v_name_it <= v_name.end (); v_name_it ++)
                {
                    cout << *v_name_it << endl;
                }
                break;
                
            case 2:
                cout << "Enter the employee ID" << endl;
                cin  >> nEmpID;
                break;

            case 3:
                cout << "Enter the department" << endl;
                cin  >> strDepartment;
                break;
                
            case 4:
                m_bFlag = false;
                break;

            default:
                cout << "Unsupported Choice, please try again" << endl;
        }
    };
    
    Log << "EXIT  : CcppTutorCompanyEmployee :: m_SearchEmployee" << endl;
    return true;
}

bool CcppTutorCompanyEmployee :: m_DeleteEmployee ()
{

    return true;
}

#if 0
CcppTutorBase :: CcppTutorBase () : m_nBasePriValue (0), m_nBasePubValue (0), m_nBaseProValue (0), m_nPriValue (0), m_nPubValue (0), m_nProValue (0)
{
}

CcppTutorBase :: ~CcppTutorBase ()
{
}

void CcppTutorBase :: m_BaseGetValue ()
{
    cout << "m_nBasePriValue : " << m_nBasePriValue << endl;
    cout << "m_nBasePubValue : " << m_nBasePubValue << endl;
    cout << "m_nBaseProValue : " << m_nBaseProValue << endl;

    cout << "m_nPriValue : " << m_nPriValue << endl;
    cout << "m_nPubValue : " << m_nPubValue << endl;
    cout << "m_nProValue : " << m_nProValue << endl;
}

void CcppTutorBase :: m_BaseSetValue (int nBasePriValue)
{
    m_nBasePriValue = nBasePriValue;
}

void CcppTutorBase :: m_WhoAmI ()
{
	cout << "I am base class" << endl;
}

/*---------------------------------*/

CcppTutorDerived :: CcppTutorDerived () : m_nDerivedPriValue (0), m_nDerivedPubValue (0), m_nDerivedProValue (0), m_nPriValue (0), m_nPubValue (0), m_nProValue (0)
{
}

CcppTutorDerived :: ~CcppTutorDerived ()
{
}

void CcppTutorDerived :: m_DerivedGetValue ()
{
    cout << "m_nDerivedPriValue : " << m_nDerivedPriValue << endl;
    cout << "m_nDerivedPubValue : " << m_nDerivedPubValue << endl;
    cout << "m_nDerivedProValue : " << m_nDerivedProValue << endl;

    cout << "m_nPriValue : " << m_nPriValue << endl;
    cout << "m_nPubValue : " << m_nPubValue << endl;
    cout << "m_nProValue : " << m_nProValue << endl;
}

void CcppTutorDerived :: m_DerivedSetValue (int nDerivedPriValue)
{
    m_nDerivedPriValue = nDerivedPriValue;
}

#ifdef INHERITANCE
void CcppTutorDerived :: m_DerivedGetBaseValue ()
{
    cout << "\n--- Accessing Base Class Values ---\n" << endl;
    cout << "Accessing Base Private - ";
    //cout << m_nBasePriValue << endl;
    cout << " [Not Accessible in derived]" << endl;

    cout << "Accessing Base Protected - "; 
    cout << m_nBaseProValue;
    cout << " [Accessible in derived]" << endl;

    cout << "Accessing Base Public - "; 
    cout << m_nBasePubValue;
    cout << " [Accessible in derived]" << endl;
}
#endif

void CcppTutorDerived :: m_WhoAmI ()
{
	cout << "I am Derived class" << endl;
}
#endif //0
